-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of generic storage equations #190
Conversation
534dc8d
to
e01b6d6
Compare
e01b6d6
to
72c0e43
Compare
I created a document to illustrate the storage concept presented in this PR and discuss the new equations suggested to be added to the model. I put it under a "temporary" folder in the doc folder. Please feel free to put in the right place. |
5db4515
to
42581a0
Compare
tests/test_storage.py
Outdated
|
||
|
||
# A function for adding sub-annual time steps to a MESSAGEix model | ||
def add_seasonality(scen, seasons_dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@behnam2015 do you think it would be worth it to make this a top-level message_ix.Scenario
function? Right now we have an add_horizon()
function which helps you set up a model. I think it would be great to have this somewhere callable by others as well! It would need to do all the required work though, so something like the year_to_time
below as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gidden, thanks for the suggestion! I agree it will be a good addition. @adrivinca also suggested that the order of each time step can be specified through a set. Now, we specifiy the time order through a parameter: time_seq
. So, add_season
or something similar can be optionally used to wrap the information related to
- a subannual time step (set
time
) - hirerachy of that time step (set
lvl_temporal
andmap_temporal_hierarchy
) - Duration of that time step (parameter
duration_time
) - The order of that time step in a year (in this PR, parameter
time_seq
)
tests/test_storage.py
Outdated
# A function for initiating sets/parameters required for storage equations | ||
# NOTICE: this function can be deleted when storage parameters/sets are added | ||
# to ixmp java backend | ||
def init_storage(scen): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we actually have support for this already in the code base~! Check out this line. I would suggest putting this there (feel free to stop by and I can show you how). Then when it gets into ixmp
, we can take it out again.
On the other hand, I would also be happy if we wanted to move this work all into python, but I'm not sure that's in the scope of this PR =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gidden for the explanation and the PR! I merged your suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! A few thoughts:
- it seems like the unit tests are not passing due to GAMS issues. can you replicate these on your machine?
- can you please transfer the text/images from
doc/temporary/Implementation of storage equations in MESSAGEix framework.docx
to the GAMS code, please? This may require some additional work on our documentation scraping tool as I am pretty sure we don't support images yet... but take a look and let me know how it goes - it is not clear why the
STORAGE_EQUALITY
constraint is needed (I probably need a bit more understanding here). shouldn't the storage unit be allowed to have different quantities at the beginning and end of each time step? - in general the test looks great; however, I must admit I really don't understand all parts of it. I would happily sit down and have you explain it to me!
Thanks @behnam2015 for the PR, I only have some comments and suggestions on the GAMS side. period_parameter_assignment.gms This is an example (not tested), but if we agree I can push changes to your branch:
Concerning
but if we don't want to be so strict, and keep a level of freedom, I think the current implementation is ok. in Finally if we agree on some of these points I can also contribute to the code |
15dc540
to
30b9a57
Compare
Thanks a lot @gidden for the feedback and useful suggestions. I will move the documentation to the GAMS files as soon as we are happy with the final equations. |
Thanks a lot @adrivinca for feedback and suggestions. I try to address them one by one:
|
Hi all - just getting back and catching up. @behnam2015, does this need another review now? |
@gidden, nothing from my side, @adrivinca may want to suggest some additions. |
Hi folks, it looks like we have some conflicts in the GAMS code. I would suggest @behnam2015 @adrivinca and @danielhuppmann decide whether this is worth trying to get into the next release or should be a first PR into master after the release is finalized. I'm happy either way if all agree. |
7da231a
to
d936a8a
Compare
Thanks @khaeru for resolving this. Yes, both tests (storage and legacy) pass after these changes. |
Unfortunately a test from
|
@francescolovat good catch—see further down at line 1827:
This is a failure in the Java database layer that happens randomly once in a while; it is spurious (doesn't signal a code error). I will restart this job. |
Ok @khaeru thanks! 🙂 |
Codecov Report
@@ Coverage Diff @@
## master #190 +/- ##
=======================================
Coverage 88.95% 88.95%
=======================================
Files 30 30
Lines 2697 2697
=======================================
Hits 2399 2399
Misses 298 298 Continue to review full report at Codecov.
|
Thanks @francescolovat for organizing the documentation very nicely and @khaeru for improving the model initialization workflow. I have no further additions or edits related to the formulation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no further additions or edits related to the formulation.
A major contribution, @behnam-zakeri—thanks to you and all others who added their code and inputs!
These comments were addressed by the author over the past year
This PR is to summarize suggestions collected through discussions with @adrivinca and @JulianHunt4 in the issue #162 for representing storage equations explicitly in the model. The concept and parameters presented in this PR are illustrated in the picture below (for more info, please see the accompanying documentation in this PR):
This PR has done the following: